package com.talent.service.iot.mqtt.task;

import com.talent.service.iot.mqtt.model.entity.TlTopic;
import com.talent.service.iot.mqtt.service.IMqttSessionService;
import com.talent.service.iot.mqtt.service.IMqttSubscriptionService;

import java.util.Set;

/**
 * @ClassName：RemoveSessionTask
 * @Author: hszhou
 * @Date: 2024/12/30 16:39
 * @Description: 必须描述类做什么事情, 实现什么功能
 */
public class RemoveSessionTask {

    private String clientId;

    private Set<TlTopic> topics;

    private IMqttSubscriptionService subscriptionService;

    private IMqttSessionService sessionService;




    public RemoveSessionTask(String clientId,
                             Set<TlTopic> topics,
                             IMqttSubscriptionService subscriptionService,
                             IMqttSessionService sessionService
                        ){
        this.clientId =clientId;
        this.topics = topics;
        this.subscriptionService = subscriptionService;
        this.sessionService = sessionService;
    }

    public void remove(){

        for (TlTopic topic : topics) {
        //    subscriptionService.clear(clientId,topic.getName());
        //    mqttStore.removeSubClientByTopic(topic.getName(), clientId);

            subscriptionService.clear(topic.getName());
        }
        sessionService.clear(clientId);
    }
}
